//
//  ZYWebImageManager.h
//  ZYWebImage
//
//  Created by wangzhipan on 2025/3/26.
//

#import <Foundation/Foundation.h>
#import "IZYWebImageProtocol.h"
#import <UIKit/UIKit.h>
#import "IZYImageCacheProtocol.h"
#import "ZYImageCache.h"
#import "ZYImageDownloader.h"
#import "ZYWebImageCombinedTask.h"

typedef void(^ZYInternalCompletionBlock)(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, ZYImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL);

NS_ASSUME_NONNULL_BEGIN

@interface ZYWebImageManager : NSObject
@property (nonatomic, strong, nullable, readonly) ZYImageCache *imageCache;
@property (nonatomic, strong, nullable, readonly) ZYImageDownloader *downloader;
@property (nonatomic, assign, readonly, getter=isRunning) BOOL running;

+ (instancetype)sharedManager;

- (nullable ZYWebImageCombinedTask *)loadImageWithUrlStr:(NSString *)urlStr
                                         enableFailRetry:(BOOL)enableFailRetry
                                               completed:(ZYInternalCompletionBlock)completed;

- (void)safeRemoveRunningTask:(nullable id<IZYTaskProtocol>)task;
- (void)cancelAll;
- (void)removeFailedUrlStr:(NSString *)urlStr;
- (void)removeAllFailedUrls;
@end

NS_ASSUME_NONNULL_END
